<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="com.damn.bean.GeneralBean,java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<link rel="SHORTCUT ICON" href="favicon.ico">
<meta name="Description" content="Facebook Post Automator" />
<meta name="Keywords" content="Facebook,Schedule Facebook Post" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="Distribution" content="Global" />
<meta name="Author" content="Dhaval Mehta - dmehta17@gmail.com" />

<link rel="stylesheet" href="images/CoolWater.css" type="text/css" />

<title>FBAuto - Schedule Post</title>
<script type="text/javascript">
function submitForm(reqType)	{
	document.FBAutoSubmit.action = '<%=request.getContextPath()%>/FBAuto?action='+reqType;
	document.FBAutoSubmit.submit();
}
function submitPic(reqType)	{
	document.uploadPic.action = '<%=request.getContextPath()%>/FBAuto?action=uploadPic';
	document.uploadPic.submit();
}
function getChecked()	{	
	var chkList = document.FBAutoSubmit.access;	
	var minOneChk = false;
	for(var i = 0;i<chkList.length;i++)	{
		if(chkList[i].checked)	{
			minOneChk = true;
		}
	}
	if(!minOneChk)	{
		alert('Select at least one profile to Post');	
	}	
	return minOneChk;
}
</script>
<%
String uName = (String)session.getAttribute("uName");
ArrayList<GeneralBean> listOfAccess = (ArrayList<GeneralBean>)(request.getSession().getAttribute("listOfAccess"));
String msgStr = (String)request.getAttribute("msgStr");
if(uName != null && !uName.equals("") && listOfAccess != null && listOfAccess.size() > 0)	{
%>
</head>

<body>
<!-- wrap starts here -->
<div id="wrap">
		
	<!--header -->
	<div id="header">			
				
		<h1 id="logo-text"><a href="main.jsp">FB Auto</a></h1>		
			
		<div id="header-links">
			<p>
			<a href="main.jsp">Home</a> | 
			<a href="#" onclick="submitForm('logout');">Logout</a>					
			</p>		
		</div>		
						
	</div>
		
	<!-- navigation -->	
	<div  id="menu">
		<ul>
			<li id="current"><a href="main.jsp">Home</a></li>
			<li><a href="schedulePost.jsp">Schedule Your Posts</a></li>			
			<li><a href="#">About</a></li>		
		</ul>
	</div>					
			
	<!-- content-wrap starts here -->
	<div id="content-wrap">
		
		<div id="main">	
			<form name="FBAutoSubmit" action = "FBAuto" method="POST" enctype="multipart/form-data">
			<input type="hidden" name = "count" value ="<%=listOfAccess.size()%>">
			<div align="right">
				<%Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("Asia/Kolkata"));	
				int curHour = calendar.get(Calendar.HOUR_OF_DAY);
				int curMin = calendar.get(Calendar.MINUTE); %>
				Current Time :-  <%=curHour %> : <%=curMin %>
			</div>			
				<fieldset>
				<legend>Select Profile to Post</legend>				
				<table>
				<% 
					
					for(int index = 0;index<listOfAccess.size();index++)	{
						GeneralBean bean = listOfAccess.get(index);
						%>
						<tr>
						<td><input type="checkbox" value="<%=bean.getAccessIndex()%>" name="access"></td>
						<td><%=bean.getAccessName()%></td>
						</tr>
					<%}%>
				</table>
				</fieldset>				
				<br/>
				<div>
				<fieldset>
				<legend>Schedule Your Post</legend>
				<div style="width: 70%;margin-left: 15%">
				<table>
				
				<%for(int i=0;i<=9;i++) {%>
				
				<tr>
				<td>Upload A photo : </td>
				<td><input type="file" name="fileIp<%=i%>"></td>
				</tr>
				
				<tr>
				<td>Write Something about this Photo : </td>
				<td><input type="text" name="caption<%=i%>"></td>
				</tr>
				
				<tr>
				<td>Select Time</td>
				<td>Hour : 
				<select name="hr<%=i%>">
				<%for (int j=0;j<=23;j++) {%>
				<option value="<%=j%>"><%=j %></option>
				<%} %>
				</select>
				Minute : 
				<select name="min<%=i%>">
				<%for (int j=0;j<=59;j++) {%>
				<option value="<%=j%>"><%=j %></option>
				<%} %>
				</select>
				</td>
				</tr>
				<tr>
				<td>&nbsp;</td>
				</tr>
				<%} %>
				<tr>				
				<td colspan="2" align="center"><input type="button" class="button" onclick="if(getChecked())submitForm('schedulePic');" value='Schedule Photos'></td>
				</tr>
				
				</table>
				</div>
				</fieldset>
				</div>
				<br/>
				
				<br/>
				<!-- <a href="schedulePost.jsp" >Schedule Your Posts</a>-->
				
				<p align="center"><a href=""></a></p>
				<br/>
				<br/>
				<%if(msgStr!= null)	{ %>
				<%=msgStr%>
				<%} %>
				<%}	else	{
					response.sendRedirect("login.jsp");
				}
				%>
			</form>
			
			<br />	
			
		</div>
		
 			
		<div id="sidebar">
		</div>
		 
	<!-- content-wrap ends here -->	
	</div>
					
	<!--footer starts here-->
	<div id="footer">
			
		<p>
		&copy; 2012 <strong>FB Auto</strong> | 
		Design by: <a href="http://www.styleshout.com/">styleshout</a> |
		Developed by : <a href="http://www.mehtadhaval.blogspot.com">Dhaval</a>	
   		</p>
				
	</div>	

<!-- wrap ends here -->
</div>

</body>
</html>
